package com.sdp.lease.db.l_tenant_apply_info.service.impl;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sdp.lease.db.l_tenant_apply_info.entity.LTenantApplyInfo;
import com.sdp.lease.db.l_tenant_apply_info.mapper.LTenantApplyInfoMapper;
import com.sdp.lease.db.l_tenant_apply_info.service.ILTenantApplyInfoService;
import com.sdp.lease.utils.LeaseConstants;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zsp
 * @since 2024-07-25
 */
@Service
public class LTenantApplyInfoServiceImpl extends ServiceImpl<LTenantApplyInfoMapper, LTenantApplyInfo> implements ILTenantApplyInfoService {

	@Override
	public LTenantApplyInfo queryTenantApplyByAccountNo(String accountNo) {
		LambdaQueryWrapper<LTenantApplyInfo> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(LTenantApplyInfo::getTenantAccountNo, accountNo);
		queryWrapper.orderByDesc(LTenantApplyInfo::getApplyTime);
		return getOne(queryWrapper,false);
	}

	@Override
	public int tenantApplyNumber() {
		LambdaQueryWrapper<LTenantApplyInfo> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(LTenantApplyInfo::getApplyState, LeaseConstants.申请状态_申请中.getCode());
		return count(queryWrapper);
	}
}
